/*
 * @Author: SeonHu
 * @Date: 2025-09-16 14:44:19
 * @LastEditors: SeonHu
 * @LastEditTime: 2025-09-23 15:37:17
 * @FilePath: \bg-vben\src\api\sys\upload.ts
 * @Description:
 * Copyright © 2020-2025 SANQING Corporation, All rights reserved.
 */
import type { AxiosProgressEvent } from 'axios';

import type { UploadApiResult } from './model/uploadModel';

import type { UploadFileParams } from '#/request';

import { useGlobSetting } from '@/hooks/setting';
import { request } from '@/utils/request/axios';

const { uploadUrl = '' } = useGlobSetting();

/**
 * @description: Upload interface
 */
export function uploadApi(params: UploadFileParams, onUploadProgress: (progressEvent: AxiosProgressEvent) => void) {
  return request.uploadFile<UploadApiResult>(
    {
      url: uploadUrl,
      onUploadProgress,
    },
    params,
  );
}
